home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
pas_0593.zip
/
DISPIC.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-05-30
|
5KB
|
147 lines
{─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
Msg : 168 of 187
From : BRIAN PAPE 1:2250/26.0 21 May 93 10:04
To : SEAN PALMER
Subj : DISPLAYING A GRAPHIC
────────────────────────────────────────────────────────────────────────────────
SP>If I remember right, a PIC file is just an uncompressed array of pixels.
SP>A 256-color PIC file is probably the easiest picture file format of all.
SP>It is set up just like an array[0..height-1,0..width-1]of byte.
SP>They usually keep the palette file separately (as a PAL file) that is an
SP>array[0..255]of record r,g,b:byte; end;
Here's how to read and display a .PIC file... (Gee, I'm posting a lot
of code today, must be in a good mood ;) That means, somebody else
get posting too... Heheh- anyway, this will *QUICKLY* read and display
a normal .PIC file, with the palette header info at the beginning. It
doesn't even try to figure it out- it assumes 320x200x256 colors- I
didn't feel like decoding anything to try to differentiate between
different fmts... It does try to tell you what the dimensions and stuff
are, just doesn't use them }
{ This program is (c) copyright 1992-1993 Brian Pape for Alphawave
Technologies and Jaeger Technologies. But, since I grab so much good
code off of the pascal echo, I suppose that anyone who reads this
message on the pascal echo, or gets it from someone who reads the
pascal echo, or.... can freely use it and all parts contained within
(or however a lawyer would say that it's *PD* :) This constitutes
over 31 minutes of hard work, btw... }
program dispic;
const
maxpicsize = 320*200;
type
pbuf = ^abuf;
abuf=array[1..maxPICSIZE] of byte;
palbuf = ^apalbuf;
apalbuf=array[1..256*3] of byte;
headerbuf=^aheaderbuf;
aheaderbuf=array[1..32] of byte;
var
f : file;
i : byte;
buf : pbuf;
pal : palbuf;
header : headerbuf;
hsize,vsize,picsize,headersize,palettesize:word;
_r,_g,_b,
cr : byte;
nr,ctr : word;
fs,overflow : longint;
filename : string;
procedure setcolreg(p:pointer;start,num:word);
begin
asm
mov ah,10h
mov al,12h { seg block of color registers }
mov bx,start
mov cx,num
mov dx,word ptr p+2 { get high word of p (seg) }
mov es,dx
mov dx,word ptr p { get low word of p (ofs) }
int $10
end;
end;
procedure stop(s:string);
begin
writeln(s);
halt;
end;
begin
writeln('DISPIC v0.01ß (c)1993 Brian Pape/Jagaer Technologies'+#10#13);
writeln(maxavail,' bytes available.');
if paramcount < 1 then
stop('no .PIC file specified.');
filename := paramstr(1);
assign(f,filename);
{$I-} reset(f,1); {$I+}
if ioresult <> 0 then
begin
writeln('file '+filename+' not found.');
halt;
end;
new(header);
writeln(maxavail,' bytes available after header allocate.');
palettesize := sizeof(pal^);
headersize := sizeof(header^);
if filesize(f) < headersize+palettesize then stop('invalid .pic file.');
blockread(f,header^,headersize,nr);
if nr < sizeof(headersize) then
stop('insufficient header information.')
else
writeln('header: ',nr,' bytes read.');
hsize := (word(header^[4]) shl 8) or header^[3];
vsize := (word(header^[6]) shl 8) or header^[5];
picsize := (word(header^[14]) shl 8) or header^[13];
writeln('picsize: ',picsize,' bytes.');
if picsize > maxpicsize then
begin
picsize := maxpicsize;
writeln('picture size read overflow. resetting to maxpicsize.');
end;
dispose(header);
new(pal);
writeln(maxavail,' bytes available after palette allocate.');
blockread(f,pal^,palettesize,nr);
if nr < palettesize then
stop('insufficient palette information.')
else
writeln('palette: ',nr,' bytes read.');
new(buf);
writeln(maxavail,' bytes available after buffer allocate.');
{$I-} blockread(f,buf^,sizeof(buf^),nr); {$I+}
if ioresult <> 0 then;
writeln('picture: ',nr,' bytes read.');
writeln('hsize: ',hsize);
writeln('vsize: ',vsize);
writeln('press enter.');
readln;
close(f);
asm
mov ah,00
mov al,$13
int $10
end;
move(buf^,ptr($a000,0)^,nr);
setcolreg(pal,0,256);
dispose(buf);
dispose(pal);
readln;
asm
mov ah,00
mov al,03
int $10
end;
end.